<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="../common/jspcommon.jsp"%>
<%@include file="../common/jscss.jsp"%>
<script type="text/javascript">
	var madeOrderGrid = null;
	var showTalkDialog=null;
	var showMadeOrderDialog=null;
	var  addTalkDialog=null;
	$(function(){
		madeOrderGrid = $("#made_order_grid").ligerGrid({
				title : '客户定制列表',
                columns: [
							{
								display: '操作', 
								name: 'identifier',
								isAllowHide: false, 
								isSort : false,
								width: 230,
								render: function (record, rowindex, value, column){
									
									var html = '<a onclick="showMadeOrder(\''+ value + '\')" href="javascript:;">订单详情</a>|&nbsp;<a onclick="answer(\''+ value + '\')" href="javascript:;">答复</a>|&nbsp;<a onclick="showTalk(\''+ value + '\')" href="javascript:;">查看对话</a>|&nbsp;<a onclick="auditAdmin(\''+ value + '\')" href="javascript:;">提交管理员</a>&nbsp;'; 
									return html; 
								}
							},
                          { display: '编号', name: 'identifier',isSort : false, width: 80},
                     	 { display: '定制阶段', name: 'stage',isSort : false,width: 80,
       	                  render: function(record, rowindex, value, column){
       	                	  if(value=='01'){
       	                		  return "<span>第一阶段</span>"; 
       	                	  }else if(value=='02'){
       	                		  return "<span>第二阶段</span>"; 
       	                	  }else if(value=='03'){
       	                		  return "<span>第三阶段</span>"; 
       	                	  }else if(value=='04'){
       	                		  return "<span>已完成</span>"; 
       	                	  }
       	                	 
       	                  }},
       	               { display: '首付款', name: 'firstPay',isSort : false,width: 80,
           	                  render: function(record, rowindex, value, column){
           	                	  if(value){
           	                		  return "<span>已付，请核对</span>"; 
           	                	  }else{
           	                		  return "<span>未付</span>"; 
           	                	  }
           	                	 
           	                  }},
           	               { display: '中间款', name: 'secondPay',isSort : false,width: 80,
               	                  render: function(record, rowindex, value, column){
               	                	  if(value){
               	                		  return "<span>已付，请核对</span>"; 
               	                	  }else{
               	                		  return "<span>未付</span>"; 
               	                	  }
               	                	 
               	                  }},
               	               { display: '尾款', name: 'thirdPay',isSort : false,width: 80,
                   	                  render: function(record, rowindex, value, column){
                   	                	  if(value){
                   	                		  return "<span>已付，请核对</span>"; 
                   	                	  }else{
                   	                		  return "<span>未付</span>"; 
                   	                	  }
                   	                	 
                   	                  }},
	                  { display: '定制人', name: 'madeName',isSort : false, width: 80},
	                  { display: '艺术家', name: 'artistName',isSort : false, width: 80},
	                  { display: '详细内容', name: 'content',isSort : false, width: 450,
       	                  render: function(record, rowindex, value, column){
       	                	 return "内容："+record.content; 
       	                  }},
       	               { display: '邮箱', name: 'email',isSort : false, width: 80},
       	            { display: '联系方式', name: 'phone',isSort : false, width: 80},
       	               { display: '地址', name: 'allArddess',isSort : false, width: 450},
                { display: '定制时间', name: 'gmtCreated',isSort : false,width: 100,
                  render: function(record, rowindex, value, column){
                	 return (new Date(value.time)).format("yyyy年MM月dd日 hh:mm:ss");
                  }}
                
                ], 
                pageSize:30,
                root :'list',
                record:'totalRecord',
                url: "/misc/artMade/madeOrderGrid.htm", 
                width: '99%',height:'99%'
            });


	});
	//查看详情
	function showTalk(madeId){
		showTalkDialog = $.ligerDialog.open({ height: 500,width:800, url: "/misc/made/showTalkListByMadeId.htm?madeId="+madeId, isResize: false ,modal:true,title:'查看对话内容'});
	}
	//查看订单详情
	function showMadeOrder(madeId){
		showMadeOrderDialog = $.ligerDialog.open({ height: 500,width:800, url: "/misc/made/showMadeOrder.htm?madeId="+madeId, isResize: false ,modal:true,title:'查看订单详情'});
	}
	//答复
	function answer(madeId){
		answerTalkDialog = $.ligerDialog.open({ height: 500,width:800, url: "/misc/made/answerTalkByMadeId.htm?madeId="+madeId, isResize: false ,modal:true,title:'回复'});
	}
	//提交管理员
	function auditAdmin(madeId){
		$.ligerDialog.confirm('你确定要提交管理员吗？', 
				function (yes){
					if(yes){
						$.post("/misc/made/isCanAudit.htm", {
							madeId:madeId
						},function(data){
							if(data=="true"){
								addTalkDialog = $.ligerDialog.open({ height: 500,width:800, url: "/misc/made/auditAdmin.htm?madeId="+madeId, isResize: false ,modal:true,title:'提交管理员'});
							}
							if(data=="false"){
								alert("该状态已提交，请等待审核。")
							}
						});
					}
				});
	}
	
</script>
<div id="made_order_grid" style="margin:0; padding:0"></div>
